<template>
	<div>
		<!--主机 选择-->
		<baseSelect 
			ref="baseSelect"
			:defaultValue="defaultValue" 
			:optionList="options" 
			:filterable="true"
			:autoSelect="autoSelect"
			@change="changeHandel"></baseSelect>
	</div>
</template>

<script>
import baseSelect from "@/view/components/select/select";
import { getActiveIp } from "@/service/swagger/HaproxyController"
import { getActiveIpPost } from "@/service/swagger/ResourceHostController"

export default {
	components: {
		baseSelect
	},
	props: [
		"defaultValue",
		"autoSelect"
	],
	data() {
		return {
			options: [],
		}
	},
	mounted() {
		//this.getData();
	},
	methods: {
		changeHandel(name, v) {
			this.$emit("change", "hostSelect", v)
		},

		getData(params) {
			let fn = params ? getActiveIp : getActiveIpPost ;
			fn(params||{}).then(ret => {
				this.options = ret.data.map(el => {
					return {
						label: el.ip,
						value: el.ip,
					}
				})
				this.$refs.baseSelect.asyncUpdateOption(this.options)
			})
		},

		reset() {
			this.$refs.baseSelect.reset()
		}
	}
}
</script>

<style>
</style>